package DAO.impl;

import DAO.BaseDao;
import DAO.BlackListDAO;
import bean.BlackList;
import bean.Users;

import java.sql.Connection;
import java.util.List;

/**
 * @author 栋
 * @date 2022/11/8
 * @description
 */
public class BlackListDAOImpl extends BaseDao<BlackList> implements BlackListDAO {
    @Override
    public int add_black(Connection conn, BlackList b) {
        String sql="insert into blacklist(user_id,introduce,black_date,black_time,admin_id) values(?,?,?,?,?)";
        return update(conn,sql,b.getUser_id(),b.getIntroduce(),b.getBlack_date(),b.getBlack_time(),b.getAdmin_id());
    }

    @Override
    public int delete_black(Connection conn, String user_id) {
        String sql="delete from blacklist where user_id=?";
        return update(conn,sql,user_id);
    }

    @Override
    public BlackList getBlackById(Connection conn, String user_id) {
        String sql="select * from blackList where user_id=?";
        return getInstance(conn,sql,user_id);
    }

    @Override
    public List<BlackList> get_all_black(Connection conn) {
        String sql="select * from blackList";
        return getForList(conn,sql);
    }
}
